package com.boardgame.example.tris.temp;

import android.app.Activity;
import android.widget.TextView;

import com.boardgame.example.tris.R;
import com.boardgame.example.tris.impl.CellaTris;
import com.boardgame.example.tris.impl.GiocatoreTris;
import com.boardgame.example.tris.impl.PezzoTris;
import com.boardgamelib.base.entity.TabelloneQuadrato;

public class TempViewSystem {
	private TextView [] cosi;
	private TextView player;
	public TempViewSystem(Activity tris) {
		cosi = new TextView [9];
		cosi[0] = (TextView)tris.findViewById(R.id.C0);
		cosi[1] = (TextView)tris.findViewById(R.id.C1);
		cosi[2] = (TextView)tris.findViewById(R.id.C2);
		
		cosi[3] = (TextView)tris.findViewById(R.id.C3);
		cosi[4] = (TextView)tris.findViewById(R.id.C4);
		cosi[5] = (TextView)tris.findViewById(R.id.C5);
		
		cosi[6] = (TextView)tris.findViewById(R.id.C6);
		cosi[7] = (TextView)tris.findViewById(R.id.C7);
		cosi[8] = (TextView)tris.findViewById(R.id.C8);
		
		player = (TextView)tris.findViewById(R.id.player);
	}
	public void tabelloneToLayout(TabelloneQuadrato<CellaTris, PezzoTris> tbq, GiocatoreTris currentPlayer) {
		for (int i = 0; i < 9; i++) {
			CellaTris cq = tbq.getCella(i);
			if (cq.getPezzo() != null) {
				PezzoTris pt = (PezzoTris)cq.getPezzo();
				cosi[i].setText(pt.getTempText());
			} else {
				cosi[i].setText("");
			}
		}
		if (currentPlayer != null)
			player.setText(currentPlayer.getNome());
		else
			player.setText("NO CURRENT PLAYER");
	}
}
